<?php

namespace App\Http\Modules;

use App\Models\Meeting;
use App\Models\UserMeeting;

/**
 * Created by PhpStorm.
 * User: thorjiang
 * Date: 2018/7/24
 * Time: 19:07
 */
class BaomingMsg extends BaseMicroMsg
{
    public function __construct()
    {
        $this->templateId = 'aXPoBM3kxBfe7Skrp6aH_XUm_eX8TTCIpct65LzeyE4';
    }

    /**
     * 名称 keyword1 》》 name
     * 电话 keywords2 >> mobile
     * 报名单位 keyword3 >> company
     * 活动名称 keywords4 >> 具体meeting name
     * 活动时间 keywords5 >>  start-end
     * 活动地点 keywords6 >>  address
     * 报名类别 keywords7 >>  A类
     * 活动费用 keywords8 >> money元
     * @param $data
     */
    public function setData($data)
    {
        $this->data['keyword1']['value'] = $data['name'];
        $this->data['keyword2']['value'] = $data['mobile'];
        $this->data['keyword3']['value'] = $data['company'];
        $this->data['keyword4']['value'] = $data['meeting_name'];
        $this->data['keyword5']['value'] = $data['time'];
        $this->data['keyword6']['value'] = $data['address'];
        $this->data['keyword7']['value'] = $data['category'];
        $this->data['keyword8']['value'] = $data['money'];
    }

    public function buildData(Meeting $meeting, $input)
    {
        $data['name'] = $input['name']; // 名字
        $data['company'] = $input['company']; // 名字
        $data['mobile'] = $input['mobile']; // 名字
        $data['meeting_name'] = $meeting->name;
        $data['time'] = date('Y-m-d', strtotime($meeting->start_time)) . "-" . date('Y-m-d', strtotime($meeting->end_time));
        $data['address'] = $meeting->address;
        $data['category'] = $input['category'];
        $data['money'] = Meeting::CATEGOEY_MAP[$input['category']] . '元';

        $this->setData($data);
    }
}